package 清洗;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class LoggerData implements WritableComparable<LoggerData> {
    private String IP;
    private String date;
    private String source;

    public int compareTo(LoggerData o) {
        int a = o.IP.compareTo(this.IP);
        if (a == 0) {
            return o.date.compareTo(date);
        }
        return a;
    }

    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(IP);
        dataOutput.writeUTF(date);
        dataOutput.writeUTF(source);
    }

    public void readFields(DataInput dataInput) throws IOException {
        IP = dataInput.readUTF();
        date = dataInput.readUTF();
        source = dataInput.readUTF();
    }

    public void set(String IP, String date, String source) {
        this.IP = IP;
        this.date = date;
        this.source = source;
    }

    @Override
    public String toString() {
        return IP+"\t"+date+"\t"+source;
    }

    public String getIP() {
        return IP;
    }

    public void setIP(String IP) {
        this.IP = IP;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }
}
